
#ifndef SX_MASS_SPRING_SIMULATION_REPLAY_CONTROLLER_H
#define SX_MASS_SPRING_SIMULATION_REPLAY_CONTROLLER_H

#include <sxMassSpringSimulationController.h>
#include <sxMassSpringSimulationRecorder.h>
#include <sxReplayable.h>
#include <sxFixedTimeline.h>

/* Sx Library Types */
using Sx::Multimedia::Replayable;
using Sx::Simulation::Recording::MassSpringSimulationRecording;
using Sx::Multimedia::FixedTimeline;

namespace Sx {
namespace Simulation {
namespace Interface {

class MassSpringSimulationReplayController : public MassSpringSimulationController, public Replayable {
public:
	MassSpringSimulationReplayController(Viewport* viewport, 
		const std::shared_ptr<Canvas>& canvas, 
		const std::shared_ptr<ScenePickingController>& pickingController, 
		const std::shared_ptr<RendererImplementation>& cameraRenderer, 
		const std::shared_ptr<MassSpringSimulation>& simulation, 
		const std::shared_ptr<MassSpringSimulationRecording>& recording);

	virtual ~MassSpringSimulationReplayController();

	/* Controller Overloads */
	void update(float dt);
	void render() const;

	void setFrameIndex(unsigned int index);
	void incrementFrameIndex();
	void decrementFrameIndex();
	bool addTimeline(const std::shared_ptr<FixedTimeline>& timeline);
	bool removeTimeline(const std::shared_ptr<FixedTimeline>& timeline);

	/* Replayable Interface Implementation */
	bool setCurrentFrame(unsigned int index);
	bool play();
	bool stop();
	bool pause();
	bool resume();
	bool isPaused();
	unsigned int size() const;

protected:
	std::shared_ptr<MassSpringSimulationRecording> recording;

	/* 
	 * Time-line interface so that a time-line can be used with a replay.
	 */
	Util::ArrayList<std::shared_ptr<FixedTimeline> > timelines;
};

}

}

}

#endif
